#include "precomp.h"
#include "AdventureDisplay.h"


AdventureDisplay::AdventureDisplay(CL_GUIComponent *parent)
	:CL_GUIComponent(parent)
{
	
	CL_Frame *fWeather = new CL_Frame(this);
	frameWeather = fWeather;
	frameWeather->set_geometry(CL_Rect(0,0,100,100));
//----Connect to event functions----------------------------------------------------------------
	//Connect to its event functions
	func_render().set(this,&AdventureDisplay::on_render);
	func_process_message().set(this, &AdventureDisplay::on_process_message);
	func_resized().set(this,&AdventureDisplay::on_resize);

//--------------------------------------------------------------------------------------------------

//-----Testing area------------------------------------------------------------------------------	

	
//--------------------------------------------------------------------------------------------------	
}


AdventureDisplay::~AdventureDisplay(void)
{
	delete frameWeather;

}



void AdventureDisplay::on_resize()
{
	if(get_geometry().get_size()!=CL_Size(0,0))
	{
		stopRender = false;
	}
	else
		stopRender = true;
}

void AdventureDisplay::on_render(CL_GraphicContext &gc, const CL_Rect &clip_rect)
{
	// begin drawing
	if(!stopRender)
	{
		CL_Rect client(CL_Point(0,0), get_geometry().get_size());
		CL_Draw::fill(gc, client, CL_Colorf::orange);
	}
}

void AdventureDisplay::on_process_message(CL_GUIMessage &message)
{
	if (!message.is_type(CL_GUIMessage_Close::get_type_name()))
	{
		
		CL_GUIMessage_Pointer msg_pointer = message;
		switch (msg_pointer.get_pointer_type())
		{
		case CL_GUIMessage_Pointer::pointer_enter:

			break;
		case CL_GUIMessage_Pointer::pointer_leave:

			break;
		}
		// Cause repaint of component:
		request_repaint();
	}
}
